<template>
  <BasicModal
    v-bind="$attrs"
    :title="t('routes.demo.partManager.useSituation')"
    @register="register"
    @ok="handleSubmit"
    @cancel="handleCloseModal"
    :destroyOnClose="true"
    :minHeight="500"
    :width="900"
  >
    <BasicTable @register="registerTable" />
  </BasicModal>
</template>

<script setup lang="ts">
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { BasicTable, useTable } from '/@/components/Table';
  import { useI18n } from '/@/hooks/web/useI18n';

  import { getUseFormConfig } from './tableData';

  // 初始化赋值
  const { t } = useI18n();

  const handleSubmit = () => {
    closeModal();
  };

  const handleCloseModal = () => {
    closeModal();
  };

  //初始化弹窗
  const [register, { setModalProps, closeModal }] = useModalInner(() => {
    setModalProps({ confirmLoading: false });
    // 设置表格数据
    setTableData([]);
    // 设置表头数据
    setColumns([]);
  });

  // 初始化表格
  const [registerTable, { setColumns, setTableData }] = useTable({
    bordered: true,
    showIndexColumn: false,
    showTableSetting: true, // 显示表格设置工具
    tableSetting: { fullScreen: true }, // 表格设置工具配置
    useSearchForm: true,
    formConfig: getUseFormConfig(), // 表单配置
    canResize: false,
    isTreeTable: true,
    childrenColumnName: 'sonList',
    rowKey: 'id',
  });
</script>

<style scoped></style>
